﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using LifeTree.DomainModel;
using LifeTree.Core.DataAccess;
using LifeTree.Core;
using LifeTree.DomainModel.Entities;
using System.IO;
using LifeTree.Mvc.ActionResults;

namespace LifeTree.Mvc.Controllers
{
    public abstract class BaseController : Controller
    {
        protected EntityFactory entityFactory;

        protected IUnitOfWork unitOfWork;

        public BaseController()
            : this(IoC.Resolve<IUnitOfWork>())
        {

        }

        public BaseController(IUnitOfWork unitOfWork)
        {
            this.unitOfWork = unitOfWork;
            this.entityFactory = new EntityFactory();
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
        }
        public new bool TryValidateModel(object model)
        {
            foreach (var item in ModelState.Values)
                item.Errors.Clear();

            return base.TryValidateModel(model);
        }

        public NotFoundResult NotFoundResult()
        {
            return new NotFoundResult();
        }
    }
}
